<?php

namespace Home\Controller;

class IndexController extends CommonController {
	
	// 首页	
	function index(){
		
// 		$file_typy = ['1.doc','1.docx','1.pdf','1.php','1.jpg','1.png','1.gif','1.bmp','1.html','1.txt','1.exe','1.rar',
// 						'11.doc','wps.docx'];
		$file_typy = ['永中office_2007_2010.doc','office_2017.doc','office_2003.doc','11.doc','word97_2000.doc','wps97-2003.doc','word_xp_2003.doc',
						
					'office_2017.docx','office_2007.docx','永中office_2007_2010.docx','wps.docx','1.pdf',];
		foreach ($file_typy as $key => $value) {
			$filename = "./Public/".$value; 
// 			dump($filename);
			$file = fopen($filename, "rb"); 
			$bin = fread($file, 2); //只读2字节 
			fclose($file); 
			$strInfo = @unpack("c2chars", $bin); 
			$typeCode = intval($strInfo['chars1'].$strInfo['chars2']);
			dump($filename.":".$typeCode);
		}	
		
		die();
		
		
		//方法跳转
		$this->display ();
	}	
	
	
	
	
	public function upload(){
		
	//判断文件上传的类型
// 	dump($_POST);
// 	dump($_FILES);
// 	echo phpinfo();
// 	die();
		
    $upload = new \Think\Upload();// 实例化上传类
    dump($upload);
    $upload->maxSize   =     3145728 ;// 设置附件上传大小
    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg','doc','docx','pdf');// 设置附件上传类型
    $upload->rootPath  =     './Public/'; // 设置附件上传根目录
    $upload->savePath  =     ''; // 设置附件上传（子）目录
    // 上传文件 
    $info   =   $upload->upload();
    dump($info);
    die();
    if(!$info) {// 上传错误提示错误信息
        $this->error($upload->getError());
    }else{// 上传成功
        $this->success('上传成功！');
    }
}
	
}